function ThreePanelResizeableControl(varName, containerId, leftHtml, rightHtml, verticalElements, windowHeightPercent, cookieName, cookieDurationDays, defaultAreaWidths)
{
	this.VariableName = varName;
	this.CurrentResizeBar = null;
	this.IsDragging = false;
	this.StartMouseX = -1;
	this.PreviousElementWidth = -1;
	this.NextElementWidth = -1;
	this.MoveFunction = null;
	this.UpFunction = null;
	this.VerticalElements = verticalElements;
	this.WindowHeightPercent = windowHeightPercent;
	this.DefaultAreaWidths = defaultAreaWidths;
	
	this.LeftHtml = leftHtml;
	this.RightHtml = rightHtml;
	
	this.ContainerElement = document.getElementById(containerId);
	this.Area1 = null;
	this.Area2 = null;
	this.Area3 = null;
	this.Resize1 = null;
	this.Resize2 = null;
	this.IsInitialized = false;
	this.CurrentContainerWidth = -1;
	this.CurrentWindowHeight = -1;
	this.ResizeWidth = -1;
	this.ContainerResizeTimeoutHandle = null;
	
	this.CookieName = cookieName;
	this.CookieDurationDays = cookieDurationDays;
	
	this.SaveState = function()
	{
		if (!this.IsInitialized || !this.CookieName)
			return;

		var totalWidth = parseInt(this.Area1.offsetWidth) + parseInt(this.Area2.offsetWidth) + parseInt(this.Area3.offsetWidth);			
		var widthString = (this.Area1.offsetWidth / totalWidth) + '_' + (this.Area2.offsetWidth / totalWidth) + "_" + (this.Area3.offsetWidth / totalWidth);
		var expires = new Date();
		exprires = expires.setTime(expires.getTime() + (this.CookieDurationDays * 24 * 60 * 60 * 1000));
		
		document.cookie = this.CookieName + "=" + widthString + "; expires=" + expires.toGMTString() + "; path=/";
	}
	
	this.StartResizing = function(element, event)
	{
		if (!this.IsInitialized)
			return;
			
		this.CurrentResizeBar = element;
		
		this.StartMouseX = event.pageX ? event.pageX : event.screenX;
		
		this.PreviousElementWidth = this.CurrentResizeBar == this.Resize1 ? parseInt(this.Area1.offsetWidth) : parseInt(this.Area2.offsetWidth);
		this.NextElementWidth = this.CurrentResizeBar == this.Resize1 ? parseInt(this.Area2.offsetWidth) : parseInt(this.Area3.offsetWidth);
		
		if (!document.documentElement.attachEvent)
		{
			this.CurrentResizeBar.onmouseup = new Function('event', 'window.' + this.VariableName + '.EndResizing(event);');
			this.CurrentResizeBar.onmousemove = new Function('event', 'window.' + this.VariableName + '.Resize(event);');
		}
		else
		{
			this.MoveFunction = new Function('event', 'window.' + this.VariableName + '.Resize(event);');
			this.UpFunction = new Function('event', 'window.' + this.VariableName + '.EndResizing(event);')
			document.documentElement.attachEvent('onmousemove', this.MoveFunction);
			document.documentElement.attachEvent('onmouseup', this.UpFunction);
		}
		
		this.IsDragging = true;
	}
	
	this.EndResizing = function(event)
	{
		if (!this.IsInitialized || !this.IsDragging)
			return;
		
		this.IsDragging = false;
		this.SaveState();
		
		if (!document.documentElement.attachEvent)
		{
			this.CurrentResizeBar.onmouseout = null;
			this.CurrentResizeBar.onmousemove = null;
		}
		else
		{
			document.documentElement.detachEvent('onmousemove', this.MoveFunction);
			document.documentElement.detachEvent('onmouseup', this.UpFunction);
		}
	}
	
	this.Resize = function(event)
	{
		if (!this.IsInitialized || !this.IsDragging)
			return;
	
		if (!event)
			event = window.event;
	
		var eventX = event.pageX ? event.pageX : event.screenX;

		try
		{
			var previousElement = this.CurrentResizeBar == this.Resize1 ? this.Area1 : this.Area2;
			var nextElement = this.CurrentResizeBar == this.Resize1 ? this.Area2 : this.Area3;
			var newPrevWidth = this.PreviousElementWidth + (eventX - this.StartMouseX);
			var newNextWidth = this.NextElementWidth + (this.StartMouseX - eventX);
		
			if (newPrevWidth >= 0 && newNextWidth >= 0)
			{
				previousElement.style.width = newPrevWidth + 'px';
				if (newPrevWidth > 0)
					previousElement.style.display = 'block';
				else
					previousElement.style.display = 'none';
			
				nextElement.style.width = newNextWidth + 'px';
				if (newNextWidth > 0)
					nextElement.style.display = 'block';
				else
					nextElement.style.display = 'none';
			}
			
			this.UpdateButtons();
		}
		catch (e)
		{
		}
	}
	
	this.ToggleCollapse = function (element, direction)
	{
		if (!this.IsInitialized)
			return;
			
		var resizeArea = element.parentNode;

		var originalWidth;	
		var leftArea;
		var rightArea;
		if (resizeArea == this.Resize1)
		{
			leftArea = this.Area1;
			rightArea = this.Area2;
		}
		else
		{
			leftArea = this.Area2;
			rightArea = this.Area3;
		}
				
		if (direction == 'right')
		{
			if (parseInt(leftArea.offsetWidth) == 0)
			{
				originalWidth = leftArea.OriginalWidth && leftArea.OriginalWidth < parseInt(rightArea.offsetWidth) ? leftArea.OriginalWidth : parseInt(rightArea.offsetWidth) / 2;
				leftArea.style.width = originalWidth + 'px';
				leftArea.style.display = 'block';
				rightArea.style.width = (parseInt(rightArea.offsetWidth) - originalWidth) + 'px';
				rightArea.style.display = 'block';
			}
			else
			{
				originalWidth = parseInt(leftArea.offsetWidth);
				leftArea.OriginalWidth = originalWidth;
				leftArea.style.width = '0px';
				leftArea.style.display = 'none';
				rightArea.style.width = (parseInt(rightArea.offsetWidth) + originalWidth) + 'px';
				if (rightArea.style.width == '0px')
					rightArea.style.display = 'none';
				else
					rightArea.style.display = 'block';
			}
		}
		else
		{
			if (parseInt(rightArea.offsetWidth) == 0)
			{
				originalWidth = rightArea.OriginalWidth && rightArea.OriginalWidth < parseInt(leftArea.offsetWidth) ? rightArea.OriginalWidth : parseInt(leftArea.offsetWidth) / 2;
				rightArea.style.width = originalWidth + 'px';
				rightArea.style.display = 'block';
				leftArea.style.width = (parseInt(leftArea.offsetWidth) - originalWidth) + 'px';
				leftArea.style.display = 'block';
			}
			else
			{
				originalWidth = parseInt(rightArea.offsetWidth);
				rightArea.OriginalWidth = originalWidth;
				rightArea.style.width = '0px';
				rightArea.style.display = 'none';
				leftArea.style.width = (parseInt(leftArea.offsetWidth) + originalWidth) + 'px';
				if (leftArea.style.width == '0px')
					leftArea.style.display = 'none';
				else
					leftArea.style.display = 'block';
			}
		}
		
		this.UpdateButtons();
		this.SaveState();
	}
	
	this.UpdateButtons = function()
	{
		if (!this.IsInitialized)
			return;
	
		this.Resize1.childNodes[0].style.display = this.Area1.style.width == '0px' ? 'none' : 'block';
		this.Resize1.childNodes[0].innerHTML = this.Area2.style.width == '0px' ? this.LeftHtml : this.RightHtml;
		this.Resize1.childNodes[1].style.display = this.Area2.style.width == '0px' ? 'none' : 'block';
		this.Resize1.childNodes[1].innerHTML = this.Area1.style.width == '0px' ? this.RightHtml : this.LeftHtml;
		this.Resize2.childNodes[0].style.display = this.Area2.style.width == '0px' ? 'none' : 'block';
		this.Resize2.childNodes[0].innerHTML = this.Area3.style.width == '0px' ? this.LeftHtml : this.RightHtml;
		this.Resize2.childNodes[1].style.display = this.Area3.style.width == '0px' ? 'none' : 'block';
		this.Resize2.childNodes[1].innerHTML = this.Area2.style.width == '0px' ? this.RightHtml : this.LeftHtml;
	}
	
	this.ResizeToContainerWidth = function()
	{
		if (!this.IsInitialized)
			return;
	
		var currentWidth = parseInt(this.ContainerElement.offsetWidth);
		if (currentWidth != this.CurrentContainerWidth)
		{
			this.CurrentContainerWidth = currentWidth;
			currentWidth -= this.ResizeWidth;			
			var totalWidth = parseInt(this.Area1.offsetWidth) + parseInt(this.Area2.offsetWidth) + parseInt(this.Area3.offsetWidth);
			
			this.Area1.style.width = ((this.Area1.offsetWidth / totalWidth) * currentWidth) + 'px';
			this.Area2.style.width = ((this.Area2.offsetWidth / totalWidth) * currentWidth) + 'px';
			this.Area3.style.width = ((this.Area3.offsetWidth / totalWidth) * currentWidth) + 'px';
		}
		
		if (this.WindowHeightPercent)
		{
			var currentHeight = parseInt(this.GetWindowHeight());
			if (currentHeight != this.CurrentWindowHeight)
			{
				this.CurrentWindowHeight = currentHeight;
				for (var i = 0; i < this.VerticalElements.length; i++)
				{
					try
					{
						currentHeight -= isNaN(parseInt(this.VerticalElements[i].offsetHeight)) ? 0 : parseInt(this.VerticalElements[i].offsetHeight);
					}
					catch (e)
					{
					}					
				}
				currentHeight *= parseFloat(this.WindowHeightPercent);				

				this.ContainerElement.style.height = currentHeight + 'px';
				this.Area1.style.height = currentHeight + 'px';
				this.Area2.style.height = currentHeight + 'px';
				this.Area3.style.height = currentHeight + 'px';
			}
		}

		window.clearTimeout(this.ContainerResizeTimeoutHandle);		
		this.ContainerResizeTimeoutHandle = window.setTimeout('window.' + this.VariableName + '.ResizeToContainerWidth();', 249);
	}
	
	this.GetWindowHeight = function()
	{
		if (window.innerHeight!=window.undefined) return window.innerHeight;
		if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
		if (document.body) return document.body.clientHeight; 
		return window.undefined; 
	}
	
	this.Initialize = function()
	{
		this.IsInitialized = false;
		
		var tr = this.ContainerElement.childNodes[0].childNodes[0].childNodes[0];
		
		this.Area1 = tr.childNodes[0].childNodes[0];
		this.Resize1 = tr.childNodes[1];
		this.Area2 = tr.childNodes[2].childNodes[0];
		this.Resize2 = tr.childNodes[3];
		this.Area3 = tr.childNodes[4].childNodes[0];
		
		this.ResizeWidth = parseInt(this.Resize1.offsetWidth) + parseInt(this.Resize2.offsetWidth);
		this.CurrentContainerWidth = -1;
		this.IsInitialized = true;
		
		var widthString = this.GetSavedState();
		if (widthString)
		{
			var widths = widthString.split('_');
			var currentWidth = parseInt(this.ContainerElement.offsetWidth);
			this.CurrentContainerWidth = currentWidth;
			currentWidth -= this.ResizeWidth;			
			
			this.Area1.style.width = (parseFloat(widths[0]) * currentWidth) + 'px';
			this.Area2.style.width = (parseFloat(widths[1]) * currentWidth) + 'px'
			this.Area3.style.width = (parseFloat(widths[2]) * currentWidth) + 'px';
		}	
		else
		{
			var currentWidth = parseInt(this.ContainerElement.offsetWidth);
			this.CurrentContainerWidth = currentWidth;
			currentWidth -= this.ResizeWidth;			
			
			this.Area1.style.width = (this.DefaultAreaWidths[0] * currentWidth) + 'px';
			this.Area2.style.width = (this.DefaultAreaWidths[1] * currentWidth) + 'px'
			this.Area3.style.width = (this.DefaultAreaWidths[2] * currentWidth) + 'px';
		}	
		
		this.UpdateButtons();
		this.ResizeToContainerWidth();
	}
	
	this.GetSavedState = function()
	{
		if (!this.CookieName)
			return;
	
		var cookies = document.cookie.split(/; /);
		var cookie;
		for (var i = 0; i < cookies.length; i++)
		{
			cookie = cookies[i].split('=', 2);
			if (cookie[0] == this.CookieName)
				return cookie[1];
		}
	}
	
	this.Initialize();
}